package com.xxl.job.kettle.service.jobhandler;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.kettle.core.executor.TransExecute;
import org.pentaho.di.core.logging.LogLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 * 实现功能：
 *
 * @author 作者[zk]
 * @version 1.0.00  2022-11-25 15:36
 */
@Component
public class KettleJob {
    private static Logger logger = LoggerFactory.getLogger(KettleJob.class);

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        System.out.println("执行了！");
        XxlJobHelper.log("XXL-JOB, Hello World.");
        TransExecute.run("D:/Program Files/my_program/data-integration/test.ktr", null, LogLevel.DEBUG, null);

//        for (int i = 0; i < 5; i++) {
//            XxlJobHelper.log("beat at:" + i);
//            TimeUnit.SECONDS.sleep(2);
//        }
        // default success
    }
}
